package com.googlecode.jch.plugin.configuration;

import com.googlecode.jch.sample.SimpleInputReader;
import com.intellij.openapi.components.*;
import com.intellij.openapi.project.Project;

import java.io.File;
import java.util.ArrayList;

/**
 * @author Iskander Akishev
 */
@State(
	name = "JCHConfiguration",
	storages = {
		@Storage(id = "default", file = "$PROJECT_FILE$"),
		@Storage(id = "dir", file = "$PROJECT_CONFIG_DIR$/jch.xml", scheme = StorageScheme.DIRECTORY_BASED)
	}
)
public class JCHConfiguration implements PersistentStateComponent<JCHConfiguration.State> {
	public static JCHConfiguration getInstance(final Project project){
		return ServiceManager.getService(project, JCHConfiguration.class);
	}

	public static class State {
		public String outputDirectory;
		public String inputReaderClass;
		public ArrayList<String> inliningPackages = new ArrayList<String>();
	}

	State state = new State();

	public JCHConfiguration(Project project) {
		state.inliningPackages = new ArrayList<String>();
		state.outputDirectory = project.getPresentableUrl() + File.separator + "submit";
		state.inputReaderClass = SimpleInputReader.class.getName();
	}

	public State getState() {
		return state;
	}

	public void loadState(State state) {
		this.state = state;
	}
}
